package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Servlet2 extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	String[] str = "零，一，二，三，四，五，六，七，八，九".split("，");
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String o = request.getParameter("o");
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < o.length(); i++) {
			try {
				Thread.sleep(3000);
				sb.append(str[Integer.parseInt(o.charAt(i) + "")]);
			} catch (InterruptedException e) {
				
				e.printStackTrace();
			}
		}
		out.println(sb);
		out.flush();
		out.close();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String o = request.getParameter("num");
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < o.length(); i++) {
			sb.append(str[Integer.parseInt(o.charAt(i) + "")]);
		}
		out.println(sb);
		out.flush();
		out.close();
	}

}
